import { defineStore } from 'pinia'
import { ref } from 'vue'
import { getRecommendVideo } from '@/api/mv'
import type { Video } from '@/types/video/index'

export const useVideoStore = defineStore('video', () => {
  const recommendMvList = ref<Array<Video>>([])
  const getRecommendMvList = async () => {
    try {
      const { data: res } = await getRecommendVideo()
      if (res.code !== 200) return ElMessage.error('操作失败')
      recommendMvList.value = res.result
    } catch (error) {
      ElMessage.error(error)
    }
  }

  return {
    recommendMvList,
    getRecommendMvList,
  }
})
